var database = require('../../data/data.js');
Page({

  data: {

  },
  onLoad: function (options) {
    wx.requestPayment({
      timeStamp: options.timeStamp,
      nonceStr: options.nonceStr,
      package: options.package + "=" + options.prepayId,
      signType: options.signType,
      paySign: options.paySign,
      complete(res) {
        console.log(res)
        if (res.errMsg == "requestPayment:ok") {
          wx.request({
            url: database.url +'/api/V2/wechat/wx_send',
            method: "POST",
            header: {
              'content-type': 'application/x-www-form-urlencoded'
            },
            data:{
              accessToken: database.accessToken,
              openId: database.openId,
              weChatId:"D0C62A3A0C1F4BBD9BA7A35351C685C7",
              stadiumId: database.stadiumId,
              prepayId: options.prepayId
            },
            success(res){
              console.log(res)
            }
          })
          wx.switchTab({
            url: "/pages/my/my",
          })
        } else {
          wx.navigateBack({

          })
        }
      }
    })
  },
})